/**
 * Copyright (c) 2008 Regents of the University of California (Regents). Created
 * by TELS, Graduate School of Education, University of California at Berkeley.
 *
 * This software is distributed under the GNU Lesser General Public License, v2.
 *
 * Permission is hereby granted, without written agreement and without license
 * or royalty fees, to use, copy, modify, and distribute this software and its
 * documentation for any purpose, provided that the above copyright notice and
 * the following two paragraphs appear in all copies of this software.
 *
 * REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE. THE SOFTWAREAND ACCOMPANYING DOCUMENTATION, IF ANY, PROVIDED
 * HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE
 * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
 *
 * IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
 * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
 * REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package org.telscenter.sail.webapp.domain.brainstorm.answer.impl;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Transient;
import javax.persistence.Version;

import org.telscenter.sail.webapp.domain.brainstorm.answer.AnswerTag;
import org.telscenter.sail.webapp.domain.workgroup.WISEWorkgroup;
import org.telscenter.sail.webapp.domain.workgroup.impl.WISEWorkgroupImpl;

/**
 * @author hirokiterashima
 * @version $Id: AnswerTagImpl.java 2325 2009-01-08 18:37:58Z honchikun $
 */
@Entity(name = AnswerTagImpl.DATA_STORE_NAME)
public class AnswerTagImpl implements AnswerTag {

	@Transient
	private static final long serialVersionUID = 1L;

	@Transient
	public static final String DATA_STORE_NAME = "brainstormanswertags";

	@Transient
	private static final String COLUMN_NAME_ANSWER_TAG_TYPE = "answer_tag_type";

	@Transient
	private static final String COLUMN_NAME_EXPLANATION = "explanation";

	@Transient
	private static final String COLUMN_NAME_OWNER_WORKGROUP_FK = "owner_workgroup_fk";

	@Column(name = AnswerTagImpl.COLUMN_NAME_ANSWER_TAG_TYPE)
	private AnswerTagType answerTagType;

	@OneToOne(targetEntity = WISEWorkgroupImpl.class, fetch = FetchType.EAGER)
	@JoinColumn(name = COLUMN_NAME_OWNER_WORKGROUP_FK, unique=false, nullable=false)
	private WISEWorkgroup ownerWorkgroup;

	@Column(name = AnswerTagImpl.COLUMN_NAME_EXPLANATION)
	private String explanation;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id = null;
    
    @Version
    @Column(name = "OPTLOCK")
    private Integer version = null;
    
	/**
	 * @see net.sf.sail.webapp.domain.Persistable#getId()
	 */
	public Serializable getId() {
		return id;
	}
	
    /**
     * @param id
     *            the id to set
     */
    @SuppressWarnings("unused")
    private void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the version
     */
    @SuppressWarnings("unused")
    private Integer getVersion() {
        return version;
    }

    /**
     * @param version
     *            the version to set
     */
    @SuppressWarnings("unused")
    private void setVersion(Integer version) {
        this.version = version;
    }

	/**
	 * @return the answerTagType
	 */
	public AnswerTagType getAnswerTagType() {
		return answerTagType;
	}

	/**
	 * @param answerTagType the answerTagType to set
	 */
	public void setAnswerTagType(AnswerTagType answerTagType) {
		this.answerTagType = answerTagType;
	}

	/**
	 * @return the ownerWorkgroup
	 */
	public WISEWorkgroup getOwnerWorkgroup() {
		return ownerWorkgroup;
	}

	/**
	 * @param ownerWorkgroup the ownerWorkgroup to set
	 */
	public void setOwnerWorkgroup(WISEWorkgroup ownerWorkgroup) {
		this.ownerWorkgroup = ownerWorkgroup;
	}

	/**
	 * @return the explanation
	 */
	public String getExplanation() {
		return explanation;
	}

	/**
	 * @param explanation the explanation to set
	 */
	public void setExplanation(String explanation) {
		this.explanation = explanation;
	};  
	
	/**
	 * @see org.telscenter.sail.webapp.domain.brainstorm.answer.AnswerTag#isTeacherAnswerTag()
	 */
	public boolean isTeacherAnswerTag() {
		return this.ownerWorkgroup.isTeacherWorkgroup();
	}

	/**
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(AnswerTag o) {
		return 0;
	}
}
